package com.ican.domain.user;

import java.io.Serializable;
import javax.persistence.*;

import com.ican.domain.common.BaseEntity;

import java.util.List;


/**
 * The persistent class for the role database table.
 * 
 */
@Entity
@Table(name="t_role")
public class Role extends BaseEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	private String name;
	private List<User> users;
	private List<Resources> resources;

    public Role() {
    }

    @Column(name="name", nullable = false)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@ManyToMany(mappedBy="roles")
	public List<User> getUsers() {
		return this.users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name="t_role_resources", joinColumns={@JoinColumn(name="role_id")}, 
	            inverseJoinColumns={@JoinColumn(name="resources_id")})
	public List<Resources> getResources() {
		return this.resources;
	}
	public void setResources(List<Resources> resources) {
		this.resources = resources;
	}
	
}